All Questions
49 questions
0votes
3answers
84views
Indexing overlapping areas of a numpy array
I have a 2D array of zeros (called labels) and a list of its coordinates (called centers). For each of the centers I would like to put a progressive number in a 5x5 cluster around it inside the label ...
0votes
1answer
38views
Indexing multiple elements in a muldimensional numpy array
I would like to extract elements of a given multidimensional numpy array, using another array of indices. However it doesn't behave in the way I expected. Below is a simple example: import numpy as np ...
0votes
4answers
63views
Multi-dimensional indexing of numpy arrays along inner axis
I have a numpy array x with shape [4, 5, 3] I have a 2D array of indices i with shape [4, 3], referring to indices along dimension 1 (of length 5) in x I'd like to extract a sub-array y from x, with ...
2votes
2answers
96views
Joining numpy arrays on matching index values in a specific column
I have multiple numpy arrays with two columns each: one containing a measurement, the other one the year of that measurement. The length and start/end points of those arrays are all different. My goal ...
0votes
0answers
31views
Selecting Array Values With A Separate Array of Indices
I am attempting to index a stacked 3-D Numpy array (named stack) by a group of 2-D indices contained inside of a separate Numpy array (named piece). The separate array contains several groups of 2-D ...
0votes
1answer
54views
how to extract indices from 2D original numpy array X based on conditions on same size array Y
I have 2 numpy arrays x_original and y_original each 50x12060 float numbers representing X and Y values that can be plotted on X-Y coordinates. I can use a filter condition on Y values like filteredY =...
0votes
1answer
47views
Error while I want to get index of specific values from my numpy array in python
I have an numpy array which I want to to find index of values from it. Here is the code: for i, memb_e in enumerate(memb_e): if memb_e == 1: x1 = e[i] y1 = 1 print(x1) for i, ...
0votes
1answer
51views
Using lexsort on higher dimensional arrays
I could not for the life of me get array indexing to work properly with higher dimensional lexsort. I have an ndarray lines of shape (N, 2, 3). You can think of it as N pairs (start and end of a line) ...
0votes
1answer
68views
Taking from index array multiple times
here is my situation. Suppose you have an array A of some elements, A is np.ndarray, and B - also np.ndarray, where B[i] is how many times I'd like to take element A[i] for the output. Example: A = np....
0votes
3answers
128views
How do I remove separate elements in a vector without using the range function?
I've created vector x and I need to create a vector z by removing the 3rd and 6th elements of x. I cannot just create a vector by simply typing in the elements that should be in z. I have to index ...
0votes
1answer
143views
Index a 3d-Torch.tensor with unique indexes for each sample along a specific axis
I am trying to index a 3-dimensional torch tensor based on timesteps acquired with torch.nonzeroes (for a latency decoder in a Neuromorphic Computing project), but am unsure on how to proceed. My ...
0votes
0answers
46views
What is the most computationally efficient way to index arrays in numpy?
I've attatched the following code that shows how I look up the index value from two arrays, then choose the Z-value corresponding to that index value. The mesh_data_X and mesh_data_Y arrays are both ...
0votes
1answer
37views
Combining two multi-dimentional numpy arrays when one of them encodes the index information, the other encodes the array content
Here is the toy version of the problem I am facing: Given the following two numpy arrays: img = np.array([[0,1,1,2], [0,2,1,1]]) number = np.array([[0,0.1,0.1,0.2], [0.1,0,0.2,0.2]]) both img and ...
1vote
0answers
30views
How to index the unique value count in numpy? [duplicate]
If the array is np.array([1, 3, 1, 5, 5, 5, 6, 3, 6, 3]), then I want to get array like this; np.array([0, 0, 1, 0, 1, 2, 0, 1, 1, 2]). Is there any numpy options? Or do I have to make new function?
0votes
0answers
69views
numpy indexing with smaller sign (<)
I have a question regarding indexing in numpy arrays. Problem that arised: While running my code I get the following error description: ValueError: zero-size array to reduction operation minimum which ...